<template>
  <div style="width:100vw;" class="teacher-box">
    <!-- <div class="record-header">
      <mt-header fixed title="我的导师">
        <router-link to="/StudyCenter" slot="left">
          <mt-button class="back-butt" icon="back"></mt-button>
        </router-link>
      </mt-header>
    </div>-->
    <div class="teacher-head">
      <div class="teacher-card">
        <div class="flex-row teacher-card-top">
          <div>
            <p class="teacher-name">{{teacherList.username}}</p>
            <p class="teacher-ms">{{teacherList.deptName}}</p>
            <p class="teacher-mss">
              <span>{{teacherList.job}}</span>
              <span class="teacher-type">导师版</span>
            </p>
          </div>
          <div :style="`background-image:url(${teacherList.photo || require('@/assets/homePicture/userpicture.png')});`" class="teacher-picture">
            <!-- <img :src="teacherList.photo || require('@/assets/homePicture/userpicture.png')" alt /> -->
          </div>
        </div>
      </div>
      <div class="teacher-item flex-row">
        <div @click="teacherAssessment" class="teacher-pj">
          <p style="font-size:22px;font-weight:800;color:#4787e4;" class="iconfont iconxueli"></p>
          <p>评价导师</p>
        </div>
        <div @click="unConcat" class="teacher-jc">
          <p
            style="font-size:22px;font-weight:800;color:#E6AC61;"
            class="iconfont iconjinyonghuiyuan"
          ></p>
          <p>解除关系</p>
        </div>
      </div>
    </div>
    <div class="deliver"></div>
    <div class="teacher-detail">
      <div class="teacher-tips">讲师简介</div>
      <div class="teacher-detail-item flex-row">
        <div class="teacher-partment">
          <span style="color:#4787e4;margin-right:5px;" class="iconfont iconweb-icon-"></span>
          <span>部门</span>
        </div>
        <div class="teacher-partment-name">{{teacherList.deptName}}</div>
      </div>
      <div class="teacher-detail-item flex-row">
        <div class="teacher-partment">
          <span style="color:#4787e4;margin-right:5px;" class="iconfont iconqiwangzhiwei"></span>
          <span>岗位</span>
        </div>
        <div class="teacher-partment-name">{{teacherList.job}}</div>
      </div>
      <div class="teacher-detail-item flex-row">
        <div class="teacher-partment">
          <span style="color:#4787e4;margin-right:5px;" class="iconfont iconxueli"></span>
          <span>学历</span>
        </div>
        <div class="teacher-partment-name">{{teacherList.edu}}</div>
      </div>
      <div class="teacher-detail-item flex-row">
        <div class="teacher-partment">
          <span style="color:#4787e4;margin-right:5px;" class="iconfont iconlingdaitie2"></span>
          <span>专业</span>
        </div>
        <div class="teacher-partment-name">{{teacherList.major}}</div>
      </div>
      <div style="margin-bottom:0;" class="teacher-detail-item flex-row">
        <div class="teacher-partment">
          <span style="color:#4787e4;margin-right:5px;" class="iconfont iconxingming"></span>
          <span>职称</span>
        </div>
        <div class="teacher-partment-name">{{teacherList.jobTitle}}</div>
      </div>
    </div>
    <!-- <div class="teacher-comment">
      <div class="teacher-comment-tips">评论区</div>
      <div class="teacher-comment-item">
        <div class="comment-top flex-row">
          <div class="comment-picture"></div>
          <div class="comment-content">
            <p class="comment-name">大傻吊</p>
            <p class="comment-type">初级工程师</p>
            <p class="comment-text">老师讲解的真的很详细呀！给老师点赞！</p>
          </div>
        </div>
        <div class="comment-time">5分钟前</div>
      </div>
    </div>-->
    <!-- <div class="deliver"></div> -->
  </div>
</template>
<script>
import { Indicator, MessageBox, Toast } from "mint-ui";
import { setText } from "../../untils/ddnavigate";
export default {
  data() {
    return {
      teacherList: {}
    };
  },
  mounted() {
    // 设置标题文字
    setText("我的导师");
    let that = this;
    let cancleFlag = that.$route.query.cancleFlag;
    if (cancleFlag == 2) {
      MessageBox.confirm("", "", {
        message: "您的导师向您发起了师徒关系解除",
        title: "提示",
        confirmButtonText: "确认",
        cancelButtonText: "驳回"
      })
        .then(status => {
          let params = {
            teaId: that.teacherList.id
          };
          that.$post("sureCancle", params).then(res => {
            if (res.success) {
              Toast({
                message: "解除成功",
                duration: 2000
              });
              setTimeout(() => {
                that.$router.push({path:'/studyCenter'});
              }, 2000);
            }
          });
        })
        .catch(status => {
          let params = {
            teaId: that.teacherList.id
          };
          that.$post("noSureCancle", params).then(res => {
            if (res.success) {
              Toast({
                message: "已驳回",
                duration: 2000
              });
              setTimeout(() => {
                that.$router.push({path:'/studyCenter'});
              }, 2000);
            }
          });
        });
    }
    this.$get("qryTeacherByStudentId").then(res => {
      if (res.success) {
        for (var key in res.data) {
          if(key == 'edu'){
            if(res.data[key] == 0){
              res.data[key] = '大专'
            }else if(res.data[key] == 1){
              res.data[key] = '本科'
            }else if(res.data[key] == 2){
              res.data[key] = '硕士'
            }else if(res.data[key] == 3){
              res.data[key] = '博士'
            }
          }
        }
        this.teacherList = res.data;
      }
    });
  },
  methods: {
    unConcat() {
      let that = this;
      let teaId = that.teacherList.id;
      let params = {
        teaId,
        cancleFlag: 2
      };
      MessageBox.confirm("确定要解除师徒关系吗？")
        .then(status => {
          that.$post("cancelRelationship", params).then(res => {
            if (res.success) {
              Toast({
                message: "已发出解除申请",
                iconClass: "mint-toast-icon mintui mintui-success",
                duration: 2000
              });
              setTimeout(() => {
                that.$router.push({path:'/studyCenter'});
              }, 2000);
            }
          });
        })
        .catch(status => {
          console.log(status);
        });
    },
    teacherAssessment(){
      let id = this.teacherList.id;
      this.$router.push({
        path:'/TeacherAssessment',
        query:{
          id
        }
      })
    }
  }
};
</script>
<style lang="less" scoped>
@import url("~@/pagecss/myteacher.less");
.btn-group {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 23/75rem 30/75rem;
  background-color: #ffffff;
}
.btn-group button {
  flex: 1 0 auto;
}
</style>